from flask import Flask, jsonify
import json

app = Flask(__name__)

@app.route("/me")
def me_api():
    return {
        "username": "ming",
        "theme": "m theme"
    }

@app.route("/users")
def users_api():
    users = [{'u':'u1', 't': 't1'}, 
             {'u':'u2', 't': 't2'}]
    # 只能返回 string, dict, tuple, Response instance, or WSGI callable
    # return users
    return jsonify([json.dumps(user) for user in users])
    # jsonify可以序列化任何支持的json数据类型